<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>上传临控人员信息</title>
    <#include "/common/resource.ftl">
    <style>
    	body{padding: 15px;}
    	.tips-container{padding: 10px;border: 1px solid #FFF3BB;background: #FFFCEE;border-radius:5px;}
    	.tips-container .title{font-weight: bold;}
    	.download-link{color: blue;text-decoration: underline;}
    	.error-container{padding: 10px;border: 1px solid #FFD7BB;background: #FFF7F0;border-radius:5px;}
    </style>
</head>
<body>
	<div class="tips-container">
		<p class="title">导入须知</p>
		<p>1）支持Microsoft Office Excel的xls及xlsx文件，点此<a class="download-link" href="${rc.contextPath}/resource/excel/bjlk.xlsx">下载导入模板</a>；</p>
		<p>2）模板中所有列的录入项不能为空；</p>
		<p>3）申请人姓名不能超过6个字（建议填写单个姓名）；</p>
		<p>4）被布控人户籍地详址及现住址不能超过40个字；</p>
		<p>5）同一个身份证号码不能重复导入；</p>
		<p>6）身份证号码须符合标准格式（六位数字地址码，八位数字出生日期码，三位数字顺序码和一位数字校验码）；</p>
	</div>
    <div class="ui-form">
        <form class="layui-form ajax-form" action="${rc.contextPath}/web/bjlkryxx/import.json" method="post">
       		<input name="id" type="hidden" value="<#if (param.id)?exists>${param.id}</#if>"/>
           	<div class="layui-form-item">
               <label class="layui-form-label" style="padding-left: 0px;">选择文件：<span class="ui-required">*</span></label>
               <div class="layui-input-block">
                   <input type="file" name="import_file" placeholder="请选择需要导入的文件" class="layui-input" maxlength="25"/>
               </div>
           	</div>
           	
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="submit" value="上传并导入人员" class="layui-btn"/>
                </div>
            </div>
        </form>
    </div>
    <div class="error-container" style="display: none;">
		错误提示：部分人员数据校验错误，请点此<a class="download-link" id="errorFile" href="">下载错误导入记录</a>，重新填写并导入！
	</div>
<script type="text/javascript">
$.fn.formSubmit = function(json) {
    var params = json || {parentRefresh:true, parentClose:true};
    var obj = $(this);
    obj.find("input[type='submit']").prop("disabled", "disabled");
    $.loading();
    obj.ajaxSubmit({
        type: "post",
        url: obj.attr("action"),
        dataType: "json",
        success: function(data){
            $.closeLoading();
            obj.find("input[type='submit']").removeAttr("disabled");
            if (params.callBack) {
                params.callBack(data);
                return false;
            }
            if (data.success) {
            	//{"code":200,"message":"请求接口成功","data":{"errorFilePath":"59ca05e7ee8f271ab4c3c36d_error.xls","status":0},"success":true}
            	obj.resetForm();
            	if(data.data.status=='1'){
            		var msg = "操作成功,本次成功布控人数"+data.data.successRow+"条";
            		layer.alert(msg, function () {
            			try{
            				if (params.parentClose) {
                                parent.layer.closeAll();
                            }
                            if (params.parentRefresh) {
                                parent.DataGrid.refresh();
                            }
            			 } catch(e){
                             if (params.parentClose) {
                                 parent.layer.closeAll();
                             }
                         }
            		});
            	} else if(data.data.status=='0'){
            		var msg = "操作成功,本次成功布控人数"+data.data.successRow+"条, 错误记录数"+data.data.failRow+"条.";
            		layer.alert(msg);
            		var hf = $(".error-container #errorFile").attr("href");
            		$(".error-container").show();
            		$(".error-container #errorFile").attr("href","${rc.contextPath}/upload/temp/"+data.data.errorFilePath);
            	} else{
            		layer.alert("未识别操作码,可能发生系统错误了.");
            	}
                return false;
            }
            layer.msg(data.message);
        }
    });
    return false;
};


</script>
</body>

</html>
